package com.ruoyi.web.controller.basedata;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.XbCommandLogs;
import com.ruoyi.basedata.service.IXbCommandLogsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小表开关阀日志Controller
 *
 * @author gdqt
 * @date 2024-03-13
 */
@RestController
@RequestMapping("/basedata/xbCommandLogs")
public class XbCommandLogsController extends BaseController {
    @Autowired
    private IXbCommandLogsService xbCommandLogsService;

    /**
     * 查询小表开关阀日志列表
     */
//    @PreAuthorize("@ss.hasAnyPermi('basedata:xbCommandLogs:list,logs:command:list')")
    @GetMapping("/list")
    public TableDataInfo list(XbCommandLogs xbCommandLogs) {
        startPage();
        List<XbCommandLogs> list = xbCommandLogsService.selectXbCommandLogsList(xbCommandLogs);
        return getDataTable(list);
    }

    /**
     * 导出小表开关阀日志列表
     */
    @PreAuthorize("@ss.hasAnyPermi('basedata:xbCommandLogs:export')")
    @Log(title = "小表开关阀日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XbCommandLogs xbCommandLogs) {
        List<XbCommandLogs> list = xbCommandLogsService.selectXbCommandLogsList(xbCommandLogs);
        ExcelUtil<XbCommandLogs> util = new ExcelUtil<XbCommandLogs>(XbCommandLogs.class);
        util.exportExcel(response, list, "小表开关阀日志数据");
    }

    /**
     * 获取小表开关阀日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:xbCommandLogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(xbCommandLogsService.selectXbCommandLogsById(id));
    }

    /**
     * 新增小表开关阀日志
     */
    @PreAuthorize("@ss.hasPermi('basedata:xbCommandLogs:add')")
    @Log(title = "小表开关阀日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XbCommandLogs xbCommandLogs) {
        return toAjax(xbCommandLogsService.insertXbCommandLogs(xbCommandLogs));
    }

    /**
     * 修改小表开关阀日志
     */
    @PreAuthorize("@ss.hasPermi('basedata:xbCommandLogs:edit')")
    @Log(title = "小表开关阀日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XbCommandLogs xbCommandLogs) {
        return toAjax(xbCommandLogsService.updateXbCommandLogs(xbCommandLogs));
    }

    /**
     * 删除小表开关阀日志
     */
    @PreAuthorize("@ss.hasPermi('basedata:xbCommandLogs:remove')")
    @Log(title = "小表开关阀日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(xbCommandLogsService.deleteXbCommandLogsByIds(ids));
    }
}
